<?php


namespace App\Http\Controllers\Api\v1;

use App\common;
use App\Logic\AnswerLogic;
use App\Models\Question;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

/**
 * @name wjy
 * Class AnswerController
 * @package App\Http\Controllers\Api\v1
 */
class AnswerController extends Controller
{
    /**
     * 问答信息展示列表
     */
    public function AnswersList(){
        try {
            $Answers=AnswerLogic::Secondary();
            return common::success(20000,$Answers,'问答列表展示成功');
        }catch (\Exception $exception) {
            return common::fail('', "", $exception->getMessage());
        }
    }
    /**
     * 问答信息添加
     */
    public function AnswersAdd(Request $request){
        try {
            $AnswersAdd=AnswerLogic::SecondaryAdd($request);
            return common::success(20000,$AnswersAdd,'问答列表信息添加成功');
        }catch (\Exception $exception){
            return common::fail('',"",$exception->getMessage());
        }
    }
    /**
     * 问答信息删除
     */
    public function AnswersDel(Request $request){
        try {
            $fangId=$request->get('id');
            $AnswersMessage=AnswerLogic::SecondaryDel($fangId);
            return common::success(20000,$AnswersMessage,'问答列表信息删除成功');
        }catch (\Exception $exception){
            return common::fail('',"",$exception->getMessage());
        }
    }
    /**
     * 问答信息查找
     */
    public function AnswersSeek(Request $request){
        try {
            $keyword = $request->input('keyword');
            $AnswersMessage=AnswerLogic::SecondarySeek($keyword);
            return common::success(20000,$AnswersMessage,'问答列表信息搜索成功');
        }catch (\Exception $exception){
            return common::fail('',"",$exception->getMessage());
        }
    }
    /**
     * 问答详情
     */
    public function AnswersDetails(Request $request){
        try {
            $fangId=$request->get('id');
            $SecondaryMessage=AnswerLogic::SecondaryDetails($fangId);
            return common::success(20000,$SecondaryMessage,'问答列表详情展示成功');
        }catch (\Exception $exception){
            return common::fail('',"",$exception->getMessage());
        }
    }
    /**
     * 问答修改
     */
    public function AnswersUpdated(Request $request){
        try {
            $SecondaryMessageUpdated = $request->post();
            $SecondaryAdd=AnswerLogic::SecondaryUpdated($SecondaryMessageUpdated);
            return common::success(20000,$SecondaryAdd,'问答列表信息修改成功');
        }catch (\Exception $exception){
            return common::fail('',"",$exception->getMessage());
        }
    }
    /**
     * 问答es搜索
     */
    public function AnswersSearch(Request $request){
        try {
            $keyword=$request->get('keyword');
            $SecondaryMessage=AnswerLogic::SecondarySearch($keyword);
            return common::success(20000,$SecondaryMessage,'问答列表es搜索成功');
        }catch (\Exception $exception){
            return common::fail('',"",$exception->getMessage());
        }
    }
}
